#include "rpganimatedsprite.h"

RpgAnimatedSprite::RpgAnimatedSprite(u8 screen, u8 id, void *data, RpgSpritePal *palette)
        : RpgSprite(screen, id, data, palette)
{
    m_animating = false;
}

void RpgAnimatedSprite::setCurrentFrame(u16 frame)
{
    if (m_animating)
    {
        stop();
    }

    m_frame = frame;

    PA_SetSpriteAnim(screen(), id(), m_frame);
}

void RpgAnimatedSprite::stop()
{
    if (m_animating)
    {
        PA_StopSpriteAnim(screen(), id());
    }

    m_animating = false;
}

void RpgAnimatedSprite::animate(u16 startFrame, u16 endFrame, s16 speed)
{
    PA_StartSpriteAnim(screen(), id(), startFrame, endFrame, speed);
    m_animating = true;
}
